* Loading and appending the "Man_" and "Kvinna_" filesforeach file in Man_100413 Man_100616 Kvinna_100413 Kvinna_100616  {display as text "`file'"insheet using "`file'.txt", cleardrop if studieid==.save `file', replace}use Man_100413, cleargen dataWave=1append using Man_100616replace dataWave=2 if missing(dataWave)drop v4*append using Man_100819save Man, replaceuse Kvinna_100413, cleargen dataWave=1append using Kvinna_100616replace dataWave=2 if missing(dataWave)append using Kvinna_100819destring attityd44, replace forcedestring attityd45, replace forcedestring attityd46, replace forcesave Kvinna, replaceappend using Mansum studieidsort studieid**** Generate a variable for respondent.gen salty_respondent=1save merged, replace******************* Merging with the bestzyg datainsheet using "salty_bestzyg_100622.txt", clearrename studiepersonid studieidsort studieidsave id, replaceuse merged.dta, clearsort studieidmerge studieid using "id.dta"***Next, we need to merge the observationsgen pair=int(twinnr/10)* Drop the subjects who are not in the SALTY data (_merge==2 refers to the subjects not in the master data in the merge)drop if _merge==2drop _mergereplace salty_respondent=0 if salty_respondent==.order studieid twinnr godk dataWave bestzyg birthdatesort studieidsave merged, replace***bys twinnr: egen min=min(dataWave )bys twinnr: egen max=max(dataWave )gen response=1replace response=2 if dataWave>mindrop if response == 2save merged, replace**** Political activity indexreplace attityd381 = 0 if attityd381 == .replace attityd382 = 0 if attityd382 == . replace attityd383 = 0 if attityd383 == . replace attityd384 = 0 if attityd384 == . replace attityd385 = 0 if attityd385 == .replace attityd386 = 0 if attityd386 == .gen polact = attityd381 + attityd382 + attityd383 + attityd384 + attityd385 + attityd386replace polact = . if attityd387 == . & polact == 0replace attityd27 = . if attityd27 == 9 gen voteparl = 1 if attityd27 < 4replace voteparl = 0 if attityd27 == 4replace attityd29 = . if attityd29 == 99gen voteeu = 1 if attityd29 < 13replace voteeu = 0 if attityd29 == 13  replace polact = polact + voteeu + voteparl* Predispositionsreplace attityd30 = . if attityd30 == 9 gen interest = abs(4 - attityd30)replace attityd39 = . if attityd39 == 99gen inteff = attityd39 - 1replace attityd40 = . if attityd40 == 99gen exteff = attityd40 - 1replace attityd34 = . if attityd34 == 99gen duty = attityd34 - 1replace attityd31 = . if attityd31 == 9gen confidence = abs(4 - attityd31)* Personalityreplace personlighet21 = . if personlighet21 == 9replace personlighet23 = . if personlighet23 == 9replace personlighet24 = . if personlighet24 == 9replace personlighet25 = . if personlighet25 == 9replace personlighet26 = . if personlighet26 == 9replace personlighet27 = . if personlighet27 == 9replace personlighet28 = . if personlighet28 == 9replace personlighet210 = . if personlighet210 == 9replace personlighet211 = . if personlighet211 == 9replace personlighet212 = . if personlighet212 == 9replace personlighet11 = . if personlighet11 == 9replace personlighet12 = . if personlighet12 == 9replace personlighet13 = . if personlighet13 == 9replace personlighet14 = . if personlighet14 == 9replace personlighet15 = . if personlighet15 == 9replace personlighet16 = . if personlighet16 == 9replace personlighet17 = . if personlighet17 == 9replace personlighet18 = . if personlighet18 == 9replace personlighet19 = . if personlighet19 == 9replace personlighet110 = . if personlighet110 == 9replace personlighet111 = . if personlighet111 == 9replace personlighet112 = . if personlighet112 == 9replace personlighet113 = . if personlighet113 == 9replace personlighet114 = . if personlighet114 == 9replace personlighet115 = . if personlighet115 == 9replace personlighet116 = . if personlighet116 == 9gen inhib = abs(3- personlighet11) + abs(3- personlighet12) + abs(3- personlighet13) + abs(personlighet14 - 1) + abs(3- personlighet15) + abs(personlighet16 - 1) + abs(3- personlighet17) + abs(3- personlighet18) + abs(personlighet19 - 1) + abs(3- personlighet110) + abs(3- personlighet111) + abs(3- personlighet112) + abs(personlighet113 - 1) + abs(3- personlighet114) + abs(personlighet115 - 1) + abs(personlighet116 - 1) gen loc = abs(2 - personlighet21) + abs(1 - personlighet23) + abs(1 - personlighet24) + abs(2 - personlighet25) + abs(2 - personlighet26) + abs(2 - personlighet27) + abs(1 - personlighet28) + abs(1 - personlighet210) + abs(1 - personlighet211) + abs(1 - personlighet212)gen extra = abs(32 - inhib)gen control = abs(10 - loc)save merged, replace* Male dummygen male = 1 if sex == 1replace male = 0 if sex == 2* Birth yeargen byear = int(birthdate/10000)save merged, replace* IQmerge twinnr using iqdrop _mergesave merged, replace* Individual IDgen sib = real(substr(string(twinnr),7,7))save merged, replacekeep if pair != .keep if bestzyg != .keep if godk == 1keep if dataWave < 3keep pair sib bestzyg male voteparl voteeu attityd381-attityd386 polact interest inteff exteff duty confidence extra control IQsave swedes, replacereshape wide bestzyg attityd381 attityd382 attityd383 attityd384 attityd385 attityd386 polact voteparl voteeu interest inteff exteff duty confidence extra control male IQ, i( pair ) j( sib )save swedes_wide, replace* Creating ordinal variablesegen extra_cut1 = cut(extra1), at(0, 2.79, 5.62, 8.44, 11.3, 14.1, 16.9, 19.7, 22.6, 25.4, 28.2, 32) icodesreplace extra_cut1 = 9 if extra_cut1 == 10 egen extra_cut2 = cut(extra2), at(0, 2.88, 5.8, 8.71, 11.6, 14.5, 17.5, 20.4, 23.3, 26.2, 29.1, 32.1) icodesreplace extra_cut2 = 9 if extra_cut2 == 10egen IQ_cut1 = cut(IQ1), at(-3,-2.81, -2.21, -1.61, -1.006, -0.404, 0.197, 0.799, 1.4, 2, 2.6, 3.2) icodesreplace IQ_cut1 = IQ_cut1 - 1egen IQ_cut2 = cut(IQ2), at(-3.1, -3,-2.37, -1.75, -1.13, -0.504, 0.12, 0.743, 1.367, 1.99, 2.61, 3.24) icodes replace IQ_cut2 = IQ_cut2 -1egen control_cut1 = cut(control1), at(0, 0.992, 1.99, 3, 3.01, 5.01, 6, 7, 8, 9, 10, 10.1) icodesreplace control_cut1 = control_cut1 - 1 if control_cut1 > 4egen control_cut2 = cut(control2), at(0, 0.992, 1.99, 3, 3.01, 5.01, 6, 7, 8, 9, 10, 10.1) icodesreplace control_cut2 = control_cut2 - 1 if control_cut2 > 4save swedes_wide, replace* Flag complete casesgen attityd381_na = 0 replace attityd381_na = 1 if attityd3811 == . | attityd3812 == .gen attityd382_na = 0 replace attityd382_na = 1 if attityd3821 == . | attityd3822 == .gen attityd383_na = 0 replace attityd383_na = 1 if attityd3831 == . | attityd3832 == .gen attityd384_na = 0 replace attityd384_na = 1 if attityd3841 == . | attityd3842 == .gen attityd385_na = 0 replace attityd385_na = 1 if attityd3851 == . | attityd3852 == .gen attityd386_na = 0 replace attityd386_na = 1 if attityd3861 == . | attityd3862 == .gen polact_na = 0 replace polact_na = 1 if polact1 == . | polact2 == .gen voteparl_na = 0 replace voteparl_na = 1 if voteparl1 == . | voteparl2 == .gen voteeu_na = 0 replace voteeu_na = 1 if voteeu1 == . | voteeu2 == .gen interest_na = 0 replace interest_na = 1 if interest1 == . | interest2 == .gen inteff_na = 0 replace inteff_na = 1 if inteff1 == . | inteff2 == .gen exteff_na = 0 replace exteff_na = 1 if exteff1 == . | exteff2 == .gen duty_na = 0 replace duty_na = 1 if duty1 == . | duty2 == .gen confidence_na = 0 replace confidence_na = 1 if confidence1 == . | confidence2 == .gen extra_na = 0 replace extra_na = 1 if extra1 == . | extra2 == .gen control_na = 0 replace control_na = 1 if control1 == . | control2 == .gen IQ_na = 0 replace IQ_na = 1 if IQ1 == . | IQ2 == .save swedes_wide, replacedrop bestzyg2 extra1 control1 IQ1 extra2 control2 IQ2* Replace missing values with -999 for MXmvencode bestzyg1 - control_cut2, mv(-999)* Write out fileoutsheet using "/Users/cdawes/Desktop/swedes.txt", nonames nolabel noquote replaceuse swedes_wide, cleardrop bestzyg2 attityd3811  - attityd3861 extra_cut1 control_cut1 IQ_cut1 voteparl1 voteeu1 attityd3812 - attityd3862 voteparl2 voteeu2 attityd3812 extra_cut2 control_cut2 IQ_cut2 attityd381_na - attityd386_na voteparl_na voteeu_namvencode bestzyg1 - IQ2, mv(-999)outsheet using "/Users/cdawes/Desktop/swedesdc.txt", nonames nolabel noquote replaceuse swedes_wide, clearreshape long bestzyg attityd381 attityd382 attityd383 attityd384 attityd385 attityd386 polact voteparl voteeu interest inteff exteff duty confidence extra control male IQ extra_cut IQ_cut control_cut ,i(pair) j(sib)* Bivariate Phenotypic Correlationspolychoric voteparl control_cut if bestzyg < 3 & voteparl_na == 0 & control_na == 0polychoric attityd381 control_cut if bestzyg < 3 & attityd381_na == 0 & control_na == 0polychoric attityd382 control_cut if bestzyg < 3 &  attityd382_na == 0 & control_na == 0polychoric polact control_cut if bestzyg < 3 &  polact_na == 0 & control_na == 0polychoric interest control_cut if bestzyg < 3 & interest_na == 0 & control_na == 0polychoric inteff control_cut if bestzyg < 3 & inteff_na == 0 & control_na == 0polychoric exteff control_cut if bestzyg < 3 & exteff_na == 0 & control_na == 0polychoric duty control_cut if bestzyg < 3 & duty_na == 0 & control_na == 0polychoric confidence control_cut if bestzyg < 3 & confidence_na == 0 & control_na == 0 polychoric voteparl extra_cut if bestzyg < 3 & voteparl_na == 0 & extra_na == 0polychoric attityd381 extra_cut if bestzyg < 3 & attityd381_na == 0 & extra_na == 0polychoric attityd382 extra_cut if bestzyg < 3 &  attityd382_na == 0 & extra_na == 0polychoric polact extra_cut if bestzyg < 3 &  polact_na == 0 & extra_na == 0polychoric interest extra_cut if bestzyg < 3 & interest_na == 0 & extra_na == 0polychoric inteff extra_cut if bestzyg < 3 & inteff_na == 0 & extra_na == 0polychoric exteff extra_cut if bestzyg < 3 & exteff_na == 0 & extra_na == 0polychoric duty extra_cut if bestzyg < 3 & duty_na == 0 & extra_na == 0polychoric confidence extra_cut if bestzyg < 3 & confidence_na == 0 & extra_na == 0polychoric voteparl IQ_cut if bestzyg < 3 & voteparl_na == 0 & IQ_na == 0polychoric attityd381 IQ_cut if bestzyg < 3 & attityd381_na == 0 & IQ_na == 0polychoric attityd382 IQ_cut if bestzyg < 3 &  attityd382_na == 0 & IQ_na == 0polychoric polact IQ_cut if bestzyg < 3 &  polact_na == 0 & IQ_na == 0polychoric interest IQ_cut if bestzyg < 3 & interest_na == 0 & IQ_na == 0polychoric inteff IQ_cut if bestzyg < 3 & inteff_na == 0 & IQ_na == 0polychoric exteff IQ_cut if bestzyg < 3 & exteff_na == 0 & IQ_na == 0polychoric duty IQ_cut if bestzyg < 3 & duty_na == 0 & IQ_na == 0polychoric confidence IQ_cut if bestzyg < 3 & confidence_na == 0 & IQ_na == 0* Summary Statisticssum voteparl if bestzyg == 1 & voteparl_na == 0sum voteparl if bestzyg == 2 & voteparl_na == 0sum voteeu if bestzyg == 1 & voteeu_na == 0sum voteeu if bestzyg == 2 & voteeu_na == 0sum attityd381 if bestzyg == 1 & attityd381_na == 0sum attityd381 if bestzyg == 2 & attityd381_na == 0sum attityd382 if bestzyg == 1 & attityd382_na == 0sum attityd382 if bestzyg == 2 & attityd382_na == 0sum attityd383 if bestzyg == 1 & attityd383_na == 0sum attityd383 if bestzyg == 2 & attityd383_na == 0sum attityd384 if bestzyg == 1 & attityd384_na == 0sum attityd384 if bestzyg == 2 & attityd384_na == 0sum attityd385 if bestzyg == 1 & attityd385_na == 0sum attityd385 if bestzyg == 2 & attityd385_na == 0sum attityd386 if bestzyg == 1 & attityd386_na == 0sum attityd386 if bestzyg == 2 & attityd386_na == 0sum polact if bestzyg == 1 & polact_na == 0sum polact if bestzyg == 2 & polact_na == 0sum interest if bestzyg == 1 & interest_na == 0sum interest if bestzyg == 2 & interest_na == 0sum inteff if bestzyg == 1 & inteff_na == 0sum inteff if bestzyg == 2 & inteff_na == 0sum exteff if bestzyg == 1 & exteff_na == 0sum exteff if bestzyg == 2 & exteff_na == 0sum duty if bestzyg == 1 & duty_na == 0sum duty if bestzyg == 2 & duty_na == 0sum confidence if bestzyg == 1 & confidence_na == 0sum confidence if bestzyg == 2 & confidence_na == 0sum control_cut if bestzyg == 1 & control_na == 0sum control_cut  if bestzyg == 2 & control_na == 0sum extra_cut if bestzyg == 1 & extra_na == 0sum extra_cut  if bestzyg == 2 & extra_na == 0sum IQ_cut if bestzyg == 1 & IQ_na == 0sum IQ_cut  if bestzyg == 2 & IQ_na == 0